package com.ruoyi.site.domain;

import java.util.Collection;
import java.util.Set;

import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.site.domain.Users;
import org.springframework.security.core.GrantedAuthority;

/**
 * 站点用户登录认证实体
 * 继承若依的 LoginUser，以便复用 TokenService 逻辑
 */
public class SiteLoginUser extends LoginUser
{
    private static final long serialVersionUID = 1L;

    /** 站点用户信息 */
    private Users siteUser;

    public SiteLoginUser(Long userId, Users siteUser, Set<String> permissions)
    {
        super(userId, 0L, null, permissions);
        this.siteUser = siteUser;
    }

    public SiteLoginUser(Long userId, String token, Users siteUser, Set<String> permissions)
    {
        this(userId, siteUser, permissions);
        this.setToken(token);
    }

    public Users getSiteUser()
    {
        return siteUser;
    }

    public void setSiteUser(Users siteUser)
    {
        this.siteUser = siteUser;
    }

    @Override
    public String getUsername()
    {
        return siteUser.getEmail();
    }
}